package zdream.control.foe.mmcommon;

import zdream.control.world.*;
import zdream.control.world.buff.HealthModule;
import zdream.control.world.buff.JumpModule;
import zdream.control.world.buff.MassModule;

import static zdream.control.world.MFoeConstants.*;

/**
 * <p>HP 大胶囊
 * <p>存在 10 秒; 锚点在中心;
 * </p>
 * 
 * @author Zdream
 * @since 0.0.1
 * @date 2022-06-13
 */
public class HPCapsuleA extends MFoe {
	public static final String NAME = "MMCommonHPCapsuleA";

	public HPCapsuleA(LevelWorld world) {
		super(world);

		this.type = TYPE_MASS;
		this.side = SIDE_NONE;
	}

	@Override
	public String foeName() {
		return NAME;
	}

	@Override
	public void init() {
		terrainHandler = new TerrainHandler(world);

		createNormalPattern()
				.withRectangle(-0.4375f, -0.4375f, 0.875f, 0.875f)
				.apply();

		healthModule = buildHealthModule()
				.outsideDestroyThreshold(1000)
				.maxAgeInMS(10000)
				.create();
		jumpModule = buildJumpModule()
				.setTerrainHandler(terrainHandler)
				.setJumpMaxDy(0)
				.create();
		massModule = buildMassModule()
				.targetSide(SIDE_PLAYER)
				.forHealing(this::createRecoverHP)
				.create();
	}

	public HealthModule healthModule;
	public JumpModule jumpModule;
	public MassModule massModule;

	public MHooks.RecoverContext createRecoverHP(MFoe foe) {
		MHooks.RecoverContext context = foe.triggerHook(MHookType.RECOVER).as();
		return context.withValue(10 * HP_TOKEN).withFoe(foe).withCauseBy(this);
	}
}
